/*
Run this script on:

        mssql-ct.db.jwan.it,1433.Caronte2014    -  This database will be modified

to synchronize it with:

        kalgan01.cs.jwan.it,1443.Jambo2014_sviluppo

You are recommended to back up your database before running this script

Script created by SQL Compare version 9.0.0 from Red Gate Software Ltd at 10/04/2014 16:05:13

*/
SET NUMERIC_ROUNDABORT OFF
GO
SET ANSI_PADDING, ANSI_WARNINGS, CONCAT_NULL_YIELDS_NULL, ARITHABORT, QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
IF EXISTS (SELECT * FROM tempdb..sysobjects WHERE id=OBJECT_ID('tempdb..#tmpErrors')) DROP TABLE #tmpErrors
GO
CREATE TABLE #tmpErrors (Error int)
GO
SET XACT_ABORT ON
GO
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
GO
BEGIN TRANSACTION
GO
PRINT N'Dropping foreign keys from [dbo].[jb_movcassabigl]'
GO
ALTER TABLE [dbo].[jb_movcassabigl] DROP
CONSTRAINT [FK_jb_movcassabigl_jb_turni],
CONSTRAINT [FK_jb_movcassabigl_causalimovim],
CONSTRAINT [FK_jb_movcassabigl_sconti],
CONSTRAINT [FK_jb_movcassabigl_catego],
CONSTRAINT [FK_jb_movcassabigl_corse],
CONSTRAINT [FK_jb_movcassabigl_itiner],
CONSTRAINT [FK_jb_movcassabigl_iva],
CONSTRAINT [FK_jb_movcassabigl_tipopagame],
CONSTRAINT [FK_jb_movcassabigl_valute]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping foreign keys from [dbo].[jb_DetTax]'
GO
ALTER TABLE [dbo].[jb_DetTax] DROP
CONSTRAINT [FK_jb_DetTax_jb_movcassabigl]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping foreign keys from [dbo].[jb_Omaggi]'
GO
ALTER TABLE [dbo].[jb_Omaggi] DROP
CONSTRAINT [FK_jb_Omaggi_jb_movcassabigl]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping foreign keys from [dbo].[jb_rendiconti]'
GO
ALTER TABLE [dbo].[jb_rendiconti] DROP
CONSTRAINT [FK_jb_rendiconti_jb_movcassabigl]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping foreign keys from [dbo].[jb_MovDettBigl]'
GO
ALTER TABLE [dbo].[jb_MovDettBigl] DROP
CONSTRAINT [FK_jb_MovDettBigl_biglie]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping foreign keys from [dbo].[jb_categoSconti]'
GO
ALTER TABLE [dbo].[jb_categoSconti] DROP
CONSTRAINT [FK_jb_categoSconti_jb_tessere_tipo]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping foreign keys from [dbo].[jb_tessere]'
GO
ALTER TABLE [dbo].[jb_tessere] DROP
CONSTRAINT [FK_jb_tessere_jb_tessere_tipo]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping constraints from [dbo].[jb_movcassabigl]'
GO
ALTER TABLE [dbo].[jb_movcassabigl] DROP CONSTRAINT [PK_jb_movcassabigl]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping constraints from [dbo].[jb_movcassabigl]'
GO
ALTER TABLE [dbo].[jb_movcassabigl] DROP CONSTRAINT [DF__tmp_rg_xx___ISAR__4B2EB2EA]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping constraints from [dbo].[jb_movcassabigl]'
GO
ALTER TABLE [dbo].[jb_movcassabigl] DROP CONSTRAINT [DF__tmp_rg_xx__CODCA__4C22D723]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping constraints from [dbo].[jb_tessere_tipo]'
GO
ALTER TABLE [dbo].[jb_tessere_tipo] DROP CONSTRAINT [PK_jb_tipo_abbonamenti]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping index [IX_jb_movcassabigl_postazioni_turni] from [dbo].[jb_movcassabigl]'
GO
DROP INDEX [IX_jb_movcassabigl_postazioni_turni] ON [dbo].[jb_movcassabigl]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping index [IX_jb_movcassabigl_biglietto_old] from [dbo].[jb_movcassabigl]'
GO
DROP INDEX [IX_jb_movcassabigl_biglietto_old] ON [dbo].[jb_movcassabigl]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Creating [dbo].[jb_postazioniStampe]'
GO
CREATE TABLE [dbo].[jb_postazioniStampe]
(
[IDPOSTAZIONE] [char] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[CODICE_STAMPA] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[IS_DEFAULT] [bit] NOT NULL DEFAULT ((1))
)
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Creating primary key [PK__jb_postazioniStampe] on [dbo].[jb_postazioniStampe]'
GO
ALTER TABLE [dbo].[jb_postazioniStampe] ADD CONSTRAINT [PK__jb_postazioniStampe] PRIMARY KEY NONCLUSTERED  ([IDPOSTAZIONE], [CODICE_STAMPA])
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Altering [dbo].[jb_MovDettBigl]'
GO
ALTER TABLE [dbo].[jb_MovDettBigl] DROP
COLUMN [CODPREN]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Rebuilding [dbo].[jb_movcassabigl]'
GO
CREATE TABLE [dbo].[tmp_rg_xx_jb_movcassabigl]
(
[IDPOSTAZIONE] [char] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[CODTURNO] [int] NOT NULL,
[ORASECONDI] [datetime] NOT NULL,
[NUMBIGL] [char] (11) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[TIPOMOV] [char] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[RIF_BIGLIETTO_OLD] [char] (11) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[CODSCO] [char] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[CATKEY] [int] NOT NULL,
[CODCORSA_PARTENZA] [char] (16) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[CODITINERA] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[QTA] [int] NOT NULL,
[ISAR] [bit] NOT NULL DEFAULT ((0)),
[IMPORTO] [decimal] (18, 2) NOT NULL,
[IMPONIBILE] [decimal] (18, 2) NOT NULL,
[IMPOSTA] [decimal] (18, 2) NOT NULL,
[IMP_ESENTE] [decimal] (18, 2) NOT NULL,
[DIR_TAX_IMPONIBILE] [decimal] (18, 2) NOT NULL,
[DIR_TAX_IMPOSTA] [decimal] (18, 2) NOT NULL,
[CODIVA] [char] (3) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[FORMAPAG] [nvarchar] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[GRATUITI] [int] NOT NULL,
[NUM_IMBARCO] [int] NOT NULL,
[CODVAL] [char] (3) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
)
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
INSERT INTO [dbo].[tmp_rg_xx_jb_movcassabigl]([IDPOSTAZIONE], [CODTURNO], [ORASECONDI], [NUMBIGL], [TIPOMOV], [RIF_BIGLIETTO_OLD], [CODSCO], [CATKEY], [CODCORSA_PARTENZA], [CODITINERA], [QTA], [ISAR], [IMPORTO], [IMPONIBILE], [IMPOSTA], [IMP_ESENTE], [DIR_TAX_IMPONIBILE], [DIR_TAX_IMPOSTA], [CODIVA], [GRATUITI], [NUM_IMBARCO], [CODVAL]) SELECT [IDPOSTAZIONE], [CODTURNO], [ORASECONDI], [NUMBIGL], [TIPOMOV], [RIF_BIGLIETTO_OLD], [CODSCO], [CATKEY], [CODCORSA_PARTENZA], [CODITINERA], [QTA], [ISAR], [IMPORTO], [IMPONIBILE], [IMPOSTA], [IMP_ESENTE], [DIR_TAX_IMPONIBILE], [DIR_TAX_IMPOSTA], [CODIVA], [GRATUITI], [NUM_IMBARCO], [CODVAL] FROM [dbo].[jb_movcassabigl]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
DROP TABLE [dbo].[jb_movcassabigl]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
EXEC sp_rename N'[dbo].[tmp_rg_xx_jb_movcassabigl]', N'jb_movcassabigl'
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Creating primary key [PK_jb_movcassabigl] on [dbo].[jb_movcassabigl]'
GO
ALTER TABLE [dbo].[jb_movcassabigl] ADD CONSTRAINT [PK_jb_movcassabigl] PRIMARY KEY CLUSTERED  ([NUMBIGL])
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Creating index [IX_jb_movcassabigl_postazioni_turni] on [dbo].[jb_movcassabigl]'
GO
CREATE NONCLUSTERED INDEX [IX_jb_movcassabigl_postazioni_turni] ON [dbo].[jb_movcassabigl] ([IDPOSTAZIONE], [CODTURNO])
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Creating index [IX_jb_movcassabigl_biglietto_old] on [dbo].[jb_movcassabigl]'
GO
CREATE NONCLUSTERED INDEX [IX_jb_movcassabigl_biglietto_old] ON [dbo].[jb_movcassabigl] ([RIF_BIGLIETTO_OLD])
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Rebuilding [dbo].[jb_tessere_tipo]'
GO
CREATE TABLE [dbo].[tmp_rg_xx_jb_tessere_tipo]
(
[TIPO_TESSERA] [int] NOT NULL IDENTITY(1, 1),
[DESCRIZIONE] [nvarchar] (40) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[PERCORSO_LIBERO] [bit] NOT NULL DEFAULT ((0))
)
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
SET IDENTITY_INSERT [dbo].[tmp_rg_xx_jb_tessere_tipo] ON
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
INSERT INTO [dbo].[tmp_rg_xx_jb_tessere_tipo]([TIPO_TESSERA], [DESCRIZIONE]) SELECT [TIPO_TESSERA], [DESCRIZIONE] FROM [dbo].[jb_tessere_tipo]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
SET IDENTITY_INSERT [dbo].[tmp_rg_xx_jb_tessere_tipo] OFF
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
DROP TABLE [dbo].[jb_tessere_tipo]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
EXEC sp_rename N'[dbo].[tmp_rg_xx_jb_tessere_tipo]', N'jb_tessere_tipo'
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Creating primary key [PK_jb_tipo_abbonamenti] on [dbo].[jb_tessere_tipo]'
GO
ALTER TABLE [dbo].[jb_tessere_tipo] ADD CONSTRAINT [PK_jb_tipo_abbonamenti] PRIMARY KEY CLUSTERED  ([TIPO_TESSERA])
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Adding foreign keys to [dbo].[jb_movcassabigl]'
GO
ALTER TABLE [dbo].[jb_movcassabigl] ADD
CONSTRAINT [FK_jb_movcassabigl_jb_turni] FOREIGN KEY ([IDPOSTAZIONE], [CODTURNO]) REFERENCES [dbo].[jb_turni] ([IDPOSTAZIONE], [CODTURNO]),
CONSTRAINT [FK_jb_movcassabigl_causalimovim] FOREIGN KEY ([TIPOMOV]) REFERENCES [dbo].[causalimovim] ([TIPOMOV]),
CONSTRAINT [FK_jb_movcassabigl_sconti] FOREIGN KEY ([CODSCO]) REFERENCES [dbo].[sconti] ([CODSCO]),
CONSTRAINT [FK_jb_movcassabigl_catego] FOREIGN KEY ([CATKEY]) REFERENCES [dbo].[catego] ([CATKEY]),
CONSTRAINT [FK_jb_movcassabigl_corse] FOREIGN KEY ([CODCORSA_PARTENZA]) REFERENCES [dbo].[corse] ([CODCORSA]),
CONSTRAINT [FK_jb_movcassabigl_itiner] FOREIGN KEY ([CODITINERA]) REFERENCES [dbo].[itiner] ([CODITINERA]),
CONSTRAINT [FK_jb_movcassabigl_iva] FOREIGN KEY ([CODIVA]) REFERENCES [dbo].[iva] ([CODIVA]),
CONSTRAINT [FK_jb_movcassabigl_pagame] FOREIGN KEY ([FORMAPAG]) REFERENCES [dbo].[pagame] ([FORMAPAG]),
CONSTRAINT [FK_jb_movcassabigl_valute] FOREIGN KEY ([CODVAL]) REFERENCES [dbo].[valute] ([CODVAL])
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Adding foreign keys to [dbo].[jb_DetTax]'
GO
ALTER TABLE [dbo].[jb_DetTax] ADD
CONSTRAINT [FK_jb_DetTax_jb_movcassabigl] FOREIGN KEY ([NUMBIGL]) REFERENCES [dbo].[jb_movcassabigl] ([NUMBIGL])
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Adding foreign keys to [dbo].[jb_Omaggi]'
GO
ALTER TABLE [dbo].[jb_Omaggi] ADD
CONSTRAINT [FK_jb_Omaggi_jb_movcassabigl] FOREIGN KEY ([NUMBIGL]) REFERENCES [dbo].[jb_movcassabigl] ([NUMBIGL])
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Adding foreign keys to [dbo].[jb_rendiconti]'
GO
ALTER TABLE [dbo].[jb_rendiconti] ADD
CONSTRAINT [FK_jb_rendiconti_jb_movcassabigl] FOREIGN KEY ([NUMBIGL]) REFERENCES [dbo].[jb_movcassabigl] ([NUMBIGL])
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Adding foreign keys to [dbo].[jb_postazioniStampe]'
GO
ALTER TABLE [dbo].[jb_postazioniStampe] ADD
CONSTRAINT [FK_jb_postazioniStampe_jb_postazioni] FOREIGN KEY ([IDPOSTAZIONE]) REFERENCES [dbo].[jb_postazioni] ([IDPOSTAZIONE]),
CONSTRAINT [FK_jb_postazioniStampe_jb_stampe] FOREIGN KEY ([CODICE_STAMPA]) REFERENCES [dbo].[jb_stampe] ([CODICE_STAMPA])
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Adding foreign keys to [dbo].[jb_categoSconti]'
GO
ALTER TABLE [dbo].[jb_categoSconti] ADD
CONSTRAINT [FK_jb_categoSconti_jb_tessere_tipo] FOREIGN KEY ([TIPO_TESSERA]) REFERENCES [dbo].[jb_tessere_tipo] ([TIPO_TESSERA])
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Adding foreign keys to [dbo].[jb_tessere]'
GO
ALTER TABLE [dbo].[jb_tessere] ADD
CONSTRAINT [FK_jb_tessere_jb_tessere_tipo] FOREIGN KEY ([TIPO_TESSERA]) REFERENCES [dbo].[jb_tessere_tipo] ([TIPO_TESSERA])
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Altering permissions on [dbo].[jb_movcassabigl]'
GO
GRANT SELECT ON  [dbo].[jb_movcassabigl] TO [JamboClient]
GRANT INSERT ON  [dbo].[jb_movcassabigl] TO [JamboClient]
GRANT DELETE ON  [dbo].[jb_movcassabigl] TO [JamboClient]
GRANT UPDATE ON  [dbo].[jb_movcassabigl] TO [JamboClient]
GRANT SELECT ON  [dbo].[jb_movcassabigl] TO [JamboGest]
GRANT INSERT ON  [dbo].[jb_movcassabigl] TO [JamboGest]
GRANT DELETE ON  [dbo].[jb_movcassabigl] TO [JamboGest]
GRANT UPDATE ON  [dbo].[jb_movcassabigl] TO [JamboGest]
GO
PRINT N'Altering permissions on [dbo].[jb_postazioniStampe]'
GO
GRANT SELECT ON  [dbo].[jb_postazioniStampe] TO [JamboClient]
GRANT SELECT ON  [dbo].[jb_postazioniStampe] TO [JamboGest]
GRANT INSERT ON  [dbo].[jb_postazioniStampe] TO [JamboGest]
GRANT DELETE ON  [dbo].[jb_postazioniStampe] TO [JamboGest]
GRANT UPDATE ON  [dbo].[jb_postazioniStampe] TO [JamboGest]
GO
PRINT N'Altering permissions on [dbo].[jb_tessere_tipo]'
GO
GRANT SELECT ON  [dbo].[jb_tessere_tipo] TO [JamboClient]
GRANT SELECT ON  [dbo].[jb_tessere_tipo] TO [JamboGest]
GRANT INSERT ON  [dbo].[jb_tessere_tipo] TO [JamboGest]
GRANT DELETE ON  [dbo].[jb_tessere_tipo] TO [JamboGest]
GRANT UPDATE ON  [dbo].[jb_tessere_tipo] TO [JamboGest]
GO
IF EXISTS (SELECT * FROM #tmpErrors) ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT>0 BEGIN
PRINT 'The database update succeeded'
COMMIT TRANSACTION
END
ELSE PRINT 'The database update failed'
GO
DROP TABLE #tmpErrors
GO
